package cn.wolfcode.luowowo.article.domain;

import cn.wolfcode.luowowo.cache.vo.QuestionStatisVO;
import cn.wolfcode.luowowo.common.domain.BaseDomain;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Getter
@Setter
public class Ask extends BaseDomain{
    public static final Integer ASK_STARUS_ISSUE = 1; //发布
    public static final Integer ASK_STARUS_AUDIT = 0; //审核
    public static final Integer ASK_STARUS_REJECT = -1; //拒绝



    private UserInfo userId;

    private Destination destId;

    private String tags;

    private String title;
    //顶
    private int topnum = 0;
    //收藏
    private int collectnum = 0;
    //浏览
    private int browsenum = 0;
    //评论
    private int commentnum = 0;
    //当前时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date nowtime;

    private int status = 0;
    //内容
    private String content;



    private QuestionStatisVO vo;


    //后台获取状态情况
    public String getStatusString(){
        String s = "";
        if (status == ASK_STARUS_ISSUE){
            s = "发布";
        }else if(status == ASK_STARUS_AUDIT){
            s = "审核";
        }else if(status == -ASK_STARUS_REJECT){
            s = "拒绝";
        }
        return s;
    }



    //后台获取标签
    public List<String> getTagsList(){
       List<String> list = new ArrayList();
        if (tags!= null){
            String[] split = tags.split(",");
            for (String s : split) {
                list.add(s);
            }
        }
        return list;
    }
}